﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PMisuseAn
{
    [Serializable()]
    public class Attribute
    {
        private string name_;
        private string literalType_;
        private bool personallyIdentifiable_;
        private bool isPrivate_;

        private List<Attribute> implied_from_;//source from target
        private List<Attribute> implied_to_; //source to target
        private List<Attribute> symmetry_; //source to target and vice versa

        //NOTE: only use inverse where there is no identified relation from direct
        private List<Attribute> implied_from_inv_;//source from target inverse
        private List<Attribute> implied_to_inv_; //source to target inverse
        private List<Attribute> symmetry_inv_; //source to target and vice versa inverse

        private List<string> aggregation_statements_;

        private List<string> domain_;
        private List<string> type_of_;

        private string category_;
        private string description_;
        private string clusterName_;
        //enum category {environmentalAttribute, regulatoryAttribute, agentAttribute};
        public enum Sensitivity { veryLow, low, medium, high, veryHigh};
        public enum Obfuscation { AccuratePrecise, AccurateImprecise,InaccuratePrecise, InccurateImprecise};

        private string activeDomain_;
        private string Value_;

        private Sensitivity sensitivityLevel_;
        private Obfuscation obfuscationLevel_;

        public Attribute()
        {
            implied_from_ = new List<Attribute>();
            implied_to_ = new List<Attribute>(); 
            symmetry_ = new List<Attribute>();

            aggregation_statements_ = new List<string>(); 

            implied_from_inv_ = new List<Attribute>();
            implied_to_inv_ = new List<Attribute>(); 
            symmetry_inv_ = new List<Attribute>();
            domain_ = new List<string>();
            type_of_ = new List<string>();
        }

        public Obfuscation obfuscationLevel
        {
            get
            {
                return obfuscationLevel_;
            }
            set
            {
                obfuscationLevel_ = value;
            }

        }
        public Sensitivity sensitivityLevel
        {
            get
            {
                return sensitivityLevel_;
            }
            set
            {
                sensitivityLevel_ = value;
            }
        }

        public string clusterName
        {
            get
            {
                return clusterName_;
            }
            set
            {
                clusterName_ = value;
            }
        }

        public string description
        {
            get
            {
                return description_;
            }
            set
            {
                description_ = value;
            }
        }

        public string category
        {
            get
            {
                return category_;
            }
            set
            {
                category_ = value;
            }
        }

        public bool isPrivate
        {
            get
            {
                return isPrivate_;
            }

            set
            {
                isPrivate_ = value;
            }
        }

        public bool personallyIdentifiable
        {
            get
            {
                return personallyIdentifiable_;
            }

            set
            {
                personallyIdentifiable_ = value;
            }
        }

        public List<Attribute> symmetry
        {
            get
            {
                return symmetry_;
            }
        }

        public List<Attribute> symmetry_inv
        {
            get
            {
                return symmetry_inv_;
            }
        }

        public void addSymmetry(Attribute att)
        {
            symmetry_.Add(att);
        }
        public void addSymmetryInv(Attribute att)
        {
            bool sym_exist = false;
            foreach (Attribute att_sym in symmetry_)
            {
                if (att_sym.name.Equals(att.name))
                {
                    sym_exist = true;
                    break;
                }
            }
            if (sym_exist == false)
            {
                symmetry_inv_.Add(att);
            }            
        }

        public void setSymmetry(List<Attribute> symmetryAtts)
        {
            symmetry_ = symmetryAtts;
        }

        public void setSymmetryInv(List<Attribute> symmetryInvAtts)
        {
            symmetry_inv_ = symmetryInvAtts;
        }

        public List<Attribute> implied_from
        {
            get
            {
                return implied_from_;
            }
        }

        public List<Attribute> implied_from_inv
        {
            get
            {
                return implied_from_inv_;
            }
        }

        public void addImpliedFrom(Attribute att)
        {
            implied_from_.Add(att);           
        }

        public void addImpliedFromInv(Attribute att)
        {
            bool imp_exist = false;
            foreach (Attribute att_imp in implied_from_)
            {
                if (att_imp.name.Equals(att.name))
                {
                    imp_exist = true;
                    break;
                }
            }
            if (imp_exist == false)
            {
                implied_from_inv_.Add(att);
            }             
        }

        public void setImpliedFrom(List<Attribute> implied_from)
        {
            implied_from_ = implied_from;
        }
        public void setImpliedFromInv(List<Attribute> implied_from_inv)
        {
            implied_from_inv_ = implied_from_inv;
        }

        public List<Attribute> implied_to
        {
            get
            {
                return implied_to_;
            }
        }

        public List<Attribute> implied_to_inv
        {
            get
            {
                return implied_to_inv_;
            }
        }

        public void addImpliedTo(Attribute implied_to)
        {
            implied_to_.Add(implied_to);
        }

        public void addImpliedToInv(Attribute att)
        {
            bool imp_exist = false;
            foreach (Attribute att_imp in implied_to_)
            {
                if (att_imp.name.Equals(att.name))
                {
                    imp_exist = true;
                    break;
                }
            }
            if (imp_exist == false)
            {
                implied_to_inv_.Add(att);
            }
        }
        public void setImpliedTo(List<Attribute> implied_to)
        {
            implied_to_ = implied_to;
        }
        public void setImpliedToInv(List<Attribute> implied_to_inv)
        {
            implied_to_inv_ = implied_to_inv;
        }

        public void addAggregationStatement(string agg_statement)
        {
            aggregation_statements_.Add(agg_statement);
        }

        public List<string> aggregation_statements
        {
            get
            {
                return aggregation_statements_;
            }
        }

        public void setAggregationStatements(List<string> agg_statements)
        {
            aggregation_statements_ = agg_statements;
        }
        
        public void addDomain(string domain_s)
        {
            bool exist = false;
            foreach (string dom in domain_)
            {
                if (dom.Equals(domain_s))
                {
                    exist = true;
                    break;
                }
            }
            if (exist == false)
            {
                domain_.Add(domain_s);
            }
        }

        public List<string> domain
        {
            get
            {
                return domain_;
            }
        }

        public void setDomain(List<string> domain)
        {
            domain_ = domain;
        }

        public void addTypeOf(string type_of_s)
        {
            type_of_.Add(type_of_s);
        }

        public List<string> type_of
        {
            get
            {
                return type_of_;
            }
        }

        public void setTypeOf(List<string> type_of)
        {
            type_of_ = type_of;
        }
        
        public string literalType
        {
            get
            {
                return literalType_;
            }
            set
            {
                literalType_ = value;
            }
        }
        public string name
        {
            get
            {
                return name_;
            }
            set
            {
                name_ = value;
            }
        }

        public string activeDomain
        {
            get
            {
                return activeDomain_;
            }
            set
            {
                activeDomain_ = value;
            }

        }

        public string attributeValue
        {
            get
            {
                return Value_;
            }
            set
            {
                Value_ = value;
            }

        }
    }
}